package com.example.comm.test;

import com.example.comm.mqtt.MqttConfiguration;
import com.example.comm.mqtt.MqttPushClient;
import com.example.comm.pojo.CarData;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

public class MqttTest {

    public static void main(String[] args) throws MqttException {
        MqttConfiguration mqttConfiguration = new MqttConfiguration();
        MqttPushClient mqttPushClient = mqttConfiguration.getMqttPushClient();
        if (null != mqttPushClient) {
            mqttPushClient.connect(mqttConfiguration.getHost(), mqttConfiguration.getClientid(), mqttConfiguration.getUsername(),
                    mqttConfiguration.getPassword(), mqttConfiguration.getTimeout(), mqttConfiguration.getKeepalive());
        }
        mqttPushClient.publish("car_data","这是一条测试消息");

    }

}
